package com.sangfor.bugreport.breakpad;

import android.content.Context;
import android.os.Environment;
import com.sangfor.bugreport.logger.Log;

/* loaded from: classes2.dex */
public class BreakpadUtils {
    private static final String TAG = "java_BreakpadUtils";
    private static String mCrashLogDir;
    private static String mLogRootDir;
    private static String mPackageName;
    private static String mProcessLogDir;
    private static String mProcessName;

    private static native void init(String str, String str2);

    public static void initBreakpad(String str, String str2) {
        if (str == null) {
            Log.error(TAG, "path is null.");
        } else if (str2 == null) {
            Log.error(TAG, "processName is null.");
        } else {
            if (str2.contains(":")) {
                str2 = str2.replace(':', '-');
            }
            Log.createDir(str);
            init(str, str2);
        }
    }

    public static void init(Context context) {
        mProcessName = Log.getProcessName(context);
        mPackageName = context.getPackageName();
        mLogRootDir = Environment.getExternalStorageDirectory().getAbsolutePath() + Log.ALLPROCESS_LOG_ROOT_DIR + mPackageName;
        mProcessLogDir = mLogRootDir + Log.PROCESS_LOG_DIR;
        String str = mLogRootDir + Log.CRASH_LOG_DIR;
        mCrashLogDir = str;
        initBreakpad(str, mProcessName);
    }
}
